package com.wangdong.newapp;


import android.support.test.runner.AndroidJUnit4;


import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Map;

@RunWith(AndroidJUnit4.class)
public class MainActivitytest {
    @Test
    public void onCreate() {

        Map<String, String> tempKeys = DLRSAUtil.createKeys(2048);

        String tpub = tempKeys.get("publicKey");
        String tpri = tempKeys.get("privateKey");

        System.out.println("publicKey:"+tpub);
        System.out.println("privateKey:"+tpri);

        String tempeStr = com.wangdong.wdutils.utils.DLRSAUtil.encryptDataByPrivateKey("123".getBytes(),DLRSAUtil.keyStrToPrivate(tpri));

        System.out.println("tempeStr:"+tempeStr);

//        String pub = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkM_BVSx2UHxnFwrYOW632jA8JjXb7h7D37HaEnlpeJTb-Vh_blGe68FdyLqH_rCuVbaiWAYCSVM8l5dzYBWtzCB8IpN0OMk5tbKn0ReAPoqNnWHul1wfJ6Cw3HM4Dw3hWbNp4lQ9u-pnedkQzWpWOVKj4oDrsK49zlEN2HRlavajBHF6c04I8xEjiXt7TznYlHHRlwHJVg46ORAzkpwH-r4QaJEd7NMjdZEEUTy5_-GM_RICU0HdBLB8EY8e6_ZHled0r7B51rhZdkyJ7VVAoALCAYxFDkvSW5hXZLGInr3ldHCBjaYc2P-wUbj4SNN1ZpYmwh3-IVubHYBiah3xCQIDAQAB";

        String encodedData=tempeStr;//"EuRkXoTyW0eI3eoY7WW7NsWBglCYFpMtCfcL0t2zJbCC8L7kGz7Id8j6X0ztc-JTWwQG_G4jLz3wZv8V3WCxgrniE2Cl2ipRlXUUDvtgfAQrrwZD2ABCw7KzqWugFcRSmVbQEgK7jeA6dLfwGCDButMHrXVN2bsxBEFSzjEkMvCiRam1o_W0iEcBI8dnpI6s66EH4FWKFMJUFwuaWarWnDfBlQxa_3_QwdbmgsVhxViFLwzclfMt19QtmIu9ca2Yy5CgC-dyvlHfcXiVDcReZZJLZ3R-6MPQTEqnU1Q_JFCyRltoqac2wiDfUbZXCA_4geQKojbcJzddE4R_Y_2FBw";
        String decodedData = com.wangdong.wdutils.utils.DLRSAUtil.decryptedToStrByPublicKey(encodedData, com.wangdong.wdutils.utils.DLRSAUtil.keyStrToPublicKey(tpub));
        System.out.println("解密后文字: \r\n" + decodedData);
    }
}
